<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>画布基础</title>
    <style>
        #c1 {
            border: 5px solid black;
        }
    </style>
</head>

<body>
    <canvas id="c1" width="400" height="400"></canvas>
</body>
<script>
    /**
    * @type {HTMLCanvasElement}
    */
    const c1 = document.querySelector("#c1");
    const ctx = c1.getContext("2d");
    //ctx它是一个画笔，所有的画笔都只有2个行为
    //1.填充  stroke   空心的
    //2.描边  fill     实心的
    ctx.font = "32px 微软雅黑";
    ctx.strokeText("标哥哥真帅", 100, 100);
    ctx.fillText("同学们也很漂亮", 100, 200);
    // -------------------------------------//

    //问题：总血量是100，当前的血量只有60，怎么画
    ctx.strokeStyle = "blue";
    ctx.strokeRect(50, 250, 300, 40);
    ctx.fillStyle = "red";
    ctx.fillRect(50, 250, 300 * 60 / 100, 40);

</script>

</html>